-- 三角形
-- Meta class 元类
Triangle = { area = 0 }

-- 基础类
function Triangle:new(o, a, b, c)
    o = o or {}
    setmetatable(o, self)
    self.__index = self
    a = a or 0
    b = b or 0
    c = c or 0
    p = (a + b + c) / 2
    self.area = math.sqrt(p * (p - a) * (p - b) * (p - c))
    return o
end

function Triangle:printArea()
    print("面积为： ", self)
end

myTriangle = Triangle:new(nil, 3, 4, 5)
myTriangle:printArea()
